You are here: Trading System Programming > Reference > Classes > Account > Account Methods > placeOrderCancel

placeOrderCancel

The placeOrderCancel method cancels open order.

Syntax

var placeOrderCancel(openOrder);

Parameters

openOrder

Valid Order object instance filled with information for an existing open order.

 

Return Value

This method returns true if order was placed successfully, false otherwise.

Remarks

In order to cancel existing order, validate that open order instance contains a valid orderId.

Example

The following example demonstrates the use of placeOrderCancel method. The code attempts to cancel all open order limit orders that match current symbol.

 

function start()

{

//retrieve short positions for all symbols

var account = getAccount();

 

var placeOrderCancel = false;

 

//determine whether order cancel needs to be placed

..

..

..

 

//if orders need to be canceled, find limit orders matching current symbol, and cancel all of them

if(placeOrderCancel)

{

//get all open orders

var orders = account.getOrders();

 

//modify all limit orders

for(var i = 0; i < orders.length; i++)

{

var openOrder = orders[i];

 

//if limit order, and if symbols match, then cancel

if(openOrder.getOrderType() == ORDERTYPE_LIMIT && openOrder.getSymbol() == this.getSymbol())

{

//submit order cancel request

var rc = account.placeOrderCancel(openOrder);

}

}

}

}

See Also

start(), getAccount(), Order Class, getSymbol()

 

 


Copyright © 2006-2009 ActiveTick LLC